<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Sql
 *
 * @author Jun Wen
 */
class Sql
{
    //put your code here
    static private $conn;

    static function connect()
    {
        if(!isset(self::$conn))
        {
            $ip = "xtmm.cn";
            $user = "a0321142909";
            $pass = "cbad58eokwlid8";
            self::$conn=mssql_connect($ip,$user,$pass);
        }
    }

    static function select($ql)
    {
        $array=null;
        $db="a0321142909";
        self::connect();
        mssql_select_db($db,self::$conn);
        $query=mssql_query($sql);
        while($rs=mssql_fetch_array($query,MSSQL_ASSOC))
        {
            $array[]=$rs;
        }
        if(count($array)==1)
        {
            $array=$array[0];
        }
        return $array;
    }

    static function insert($sql)
    {
        self::connect();
        mssql_select_db($db,self::$conn);
        return mssql_query($sql);
    }

    static function update($sql)
    {
        self::connect();
        mssql_select_db($db,self::$conn);
        return mssql_query($sql);
    }
}
?>
